package models;

import java.util.*;

import javax.persistence.*;
 
import play.db.jpa.*;

@Entity
public class ClubUser extends User{
	
	@OneToMany(mappedBy="club", cascade=CascadeType.ALL)
	public List<Member> members;
	
	public ClubUser(String userName, String password, String email, String name) {
		super(userName, password, email, name);
		members = new ArrayList<Member>();
	}

	public ClubUser(String userName, String password, String email, String name, String desc) {
		super(userName, password, email, name, desc);
		members = new ArrayList<Member>();
	}
	
	public ClubUser addMember(String name, String email, String hometown, 
			String address, Date activationEnds) {
		Member newMember = 
			new Member(this, name, email, hometown, address, activationEnds);
		this.members.add(newMember);
		this.save();
		return this;
	}
}
